package requests.settings;

import java.io.BufferedReader;
import java.io.FileReader;

import requests.IRequest;
import main.DemiGui;

public class ReadSettings implements IRequest {
	private DemiGui instance;
	
	public ReadSettings(DemiGui instance) {
		this.instance = instance;
	}

	
	public String read(String filePath) {
		
		String textLine = "", text = "";

         try {      	 	
        	  FileReader fileReader = new FileReader(filePath);
        	  BufferedReader bufferedReader = new BufferedReader(fileReader);
        	 
        	  textLine = bufferedReader.readLine();
        	  text += textLine;
        	  do {
        		  textLine = bufferedReader.readLine();
        		  text += textLine;
        	  } 
        	  while(textLine != null);
        	  
        	  bufferedReader.close();
         }
         catch (Exception e) {
        	 returnDEMI("I cannot open settings.txt");
         }

		return text;
	}


	@Override
	public void returnDEMI(String text) {
		instance.Monitor(text);
		
	}
	
}
